<template>
	<view class="page">
		<view class="searchRow">
			<u-search v-model="params.memberName" placeholder="请输入姓名" :showAction="true" actionText="搜索"
			:animation="true" @search="goSearch"></u-search>
		</view>
		<scroll-view scroll-y="true" style="height: calc( 100vh - 128rpx );">
			<view class="list">
				<scollerXTabel itemWidth="190rpx" :fixedField="fixedField" :tableArr="studentList" 
					@handleRowEmit="handleSelectRow"></scollerXTabel>
			</view>
		</scroll-view>
		
			
	</view>
</template>

<script>
	import {pageMemberApi} from '@/common/api/commonApi/commonApi.js'
	import scollerXTabel from '@/components/scollerXTabel.vue'
	export default {
		data() {
			return {
				studentList:[],
				params:{
					mainframeNo : '',
					memberName: '',
					currPage : 1,
					pageSize : 999
				},
				fixedField:[
					{
						val: 'memberNo',
						lable: '学号',
					},
					{
						val: 'memberName',
						lable: '姓名',
					},
					{
						val: 'subsidiaryName',
						lable: '所属部门',
					},
					{
						val: 'option',
						lable: '操作',
					},
					
				],
			}
		},
		components:{
			scollerXTabel,
		},
		methods: {
			handleSelectRow(e){
				console.log(e);
				uni.showModal({
					title:'提示',
					content:'确认要选该学号吗？',
					success:(res)=> {
						if(res.confirm){
							uni.$emit('selectUser',{
								memberNo : e.memberNo
							})
							this.goBack()
						}
					}
				})
			},
			getStudentList(){
				this.params.mainframeNo = this.$Route.query.schoolNo
				pageMemberApi(this.params).then(res=>{
					if(res.data.list.length){
						res.data.list.forEach(item=>{
							item.option = '选择'
						})
					}
					this.studentList = res.data.list
				})
			},
			goSearch(){
				if(!this.params.memberName) return this.setMessage('请先输入姓名')
				this.params.currPage = 1
				this.getStudentList()
			}
			
		},
		onLoad() {
			// this.getStudentList()
		},
		onShow() {
			
		},
	}
</script>

<style lang="scss" scoped>
.page{
	background-color: #fff;
	height: 100vh;
	.searchRow{
		height: 128rpx;
		display: flex;
		align-items: center;
	}
}
</style>
